home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / ksieve / lexer.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-09-10  |  3.3 KB  |  109 lines

  1. /*  -*- c++ -*-
  2.     ksieve/lexer.h
  3.  
  4.     This file is part of KSieve,
  5.     the KDE internet mail/usenet news message filtering library.
  6.     Copyright (c) 2003 Marc Mutz <mutz@kde.org>
  7.  
  8.     KSieve is free software; you can redistribute it and/or modify it
  9.     under the terms of the GNU General Public License, version 2, as
  10.     published by the Free Software Foundation.
  11.  
  12.     KSieve is distributed in the hope that it will be useful, but
  13.     WITHOUT ANY WARRANTY; without even the implied warranty of
  14.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15.     General Public License for more details.
  16.  
  17.     You should have received a copy of the GNU General Public License
  18.     along with this program; if not, write to the Free Software
  19.     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  20.  
  21.     In addition, as a special exception, the copyright holders give
  22.     permission to link the code of this program with any edition of
  23.     the Qt library by Trolltech AS, Norway (or with modified versions
  24.     of Qt that use the same license as Qt), and distribute linked
  25.     combinations including the two.  You must obey the GNU General
  26.     Public License in all respects for all of the code used other than
  27.     Qt.  If you modify this file, you may extend this exception to
  28.     your version of the file, but you are not obligated to do so.  If
  29.     you do not wish to do so, delete this exception statement from
  30.     your version.
  31. */
  32.  
  33. #ifndef __KSIEVE_LEXER_H__
  34. #define __KSIEVE_LEXER_H__
  35.  
  36. class QString;
  37.  
  38. namespace KSieve {
  39.  
  40.   class Error;
  41.  
  42.   class Lexer {
  43.   public:
  44.     enum Options {
  45.       IncludeComments = 0,
  46.       IgnoreComments = 1,
  47.       IncludeLineFeeds = 0,
  48.       IgnoreLineFeeds = 2
  49.     };
  50.  
  51.     Lexer( const char * scursor, const char * send, int options=0 );
  52.     ~Lexer();
  53.  
  54.     /** Return whether comments are returned by @ref
  55.     nextToken. Default is to not ignore comments. Ignoring them
  56.     can speed up script parsing a bit, and can be used when the
  57.     internal representation of the script won't be serialized into
  58.     string form again (or if you simply want to delete all
  59.     comments)
  60.     **/
  61.     bool ignoreComments() const;
  62.  
  63.     /** Return whether line feeds are returned by @ref
  64.     nextToken. Default is to not ignore line feeds. Ignoring them
  65.     can speed up script parsing a bit, and can be used when the
  66.     internal representation of the script won't be serialized into
  67.     string form again.
  68.     **/
  69.     bool ignoreLineFeeds() const;
  70.  
  71.     const Error & error() const;
  72.  
  73.     bool atEnd() const;
  74.     int column() const;
  75.     int line() const;
  76.  
  77.     enum Token {
  78.       None = 0,
  79.       Number,          // 1, 100, 1M, 10k, 1G, 2g, 3m
  80.       Identifier,      // atom
  81.       Tag,             // :tag
  82.       Special,         // {} [] () ,;
  83.       QuotedString,    // "foo\"bar" -> foo"bar
  84.       MultiLineString, // text: \nfoo\n. -> foo
  85.       HashComment,     // # foo
  86.       BracketComment,  // /* foo */
  87.       LineFeeds        // the number of line feeds encountered
  88.     };
  89.  
  90.     /** Parse the next token and return it's type. @p result will contain
  91.     the value of the token. */
  92.     Token nextToken( QString & result );
  93.  
  94.     void save();
  95.     void restore();
  96.       
  97.     class Impl;
  98.   private:
  99.     Impl * i;
  100.  
  101.   private:
  102.     const Lexer & operator=( const Lexer & );
  103.     Lexer( const Lexer & );
  104.   };
  105.  
  106. } // namespace KSieve
  107.  
  108. #endif // __KSIEVE_LEXER_H__
  109.